package com.auxgroup.smarthome.entity;


import com.auxgroup.smarthome.basebean.MenuTypeEnum;
import com.auxgroup.smarthome.session.SessionMenu;

import javax.persistence.*;
import javax.persistence.Entity;

/**
 * Created by kevinchen on 2016/12/24.
 */
@Entity
@Table(name = "sys_permission")
public class MenuEntity extends AbstractGenericEntity {
    @Id
    @Column(length = 200, unique = true)
    private String id;

    @Column(length = 250,unique = true)
    private String menuName;

    @Column(length = 50)
    private String parentId;

    @Enumerated(EnumType.ORDINAL)
    @Column
    private MenuTypeEnum menuType;

    @Column(length = 100,unique = true)
    private String lableKey;

    @Column(length = 4)
    private Integer sortNum = 0;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getMenuName() {
        return menuName;
    }

    public void setMenuName(String menuName) {
        this.menuName = menuName;
    }

    public String getParentId() {
        return parentId;
    }

    public void setParentId(String parentId) {
        this.parentId = parentId;
    }

    public MenuTypeEnum getMenuType() {
        return menuType;
    }

    public void setMenuType(MenuTypeEnum menuType) {
        this.menuType = menuType;
    }

    public String getLableKey() {
        return lableKey;
    }

    public void setLableKey(String lableKey) {
        this.lableKey = lableKey;
    }

    public Integer getSortNum() {
        return sortNum;
    }

    public void setSortNum(Integer sortNum) {
        this.sortNum = sortNum;
    }

    public MenuEntity() {
    }

    public MenuEntity(String id,String menuName, String parentId, MenuTypeEnum menuType,String lableKey){
        this.id = id;
        this.menuName = menuName;
        this.parentId = parentId;
        this.menuType = menuType;
        this.lableKey = lableKey;
    }

    public MenuEntity(String menuName, String parentId, MenuTypeEnum menuType, String lableKey, Integer sortNum) {
        this.menuName = menuName;
        this.parentId = parentId;
        this.menuType = menuType;
        this.lableKey = lableKey;
        this.sortNum = sortNum;
    }

    public SessionMenu createSessionMenu(){
        return new SessionMenu(getId(),menuName,parentId,menuType,lableKey,sortNum);
    }

}
